﻿$(function () {
    $('#surveySubmit').click(function () {
        // CheckForm();
        // var isopen = 1;
        // if ($("#Survey_isOpen").is(":checked")) {
        //     isopen=0;
        // }
        var postdata = "id=" + $.trim($("#Survey_id").val()) + "&name=" + $.trim($("#Survey_name").val())
            + "&author=" + $.trim($("#Survey_author").val())+ "&desc=" + $.trim($("#Survey_description").val())
            + "&endtime=" + $.trim($("#Survey_ExpireDate").val())+ "&isopenBoolean=" + $("#Survey_isOpen").is(":checked");
        $.post("/admin/survey/editSurvey", postdata, function (data) {
            if (data.code == 200) {
                alert("修改成功");
                window.location.href="/surveyAdmin/list?pageCode=1";
            } else {
                alert("修改失败");
            }
        }, "json");
    });

});

function CheckForm() {

    if (document.getElementById('Survey_name').value == "") {
        alert("请输入问卷名称");
        return false;
    } else if (document.getElementById('Survey_author').value == "") {
        alert("请输入问卷发起人(单位)");
        //alert(document.getElementById('Survey_isPassword').value);
        return false;
    } else {
        var obj = document.getElementById("Survey_ipList");
        var ipRange = document.getElementById("Survey_ipRange");
        for (var i = 0; i < obj.options.length; i++) {
            var ipvalue = obj.options[i].value;
            if (ipRange.value == "")//第一个分号处理
                document.getElementById("Survey_ipRange").value = ipvalue;
            else
                document.getElementById("Survey_ipRange").value = document.getElementById("Survey_ipRange").value + ";" + ipvalue;
        }

        return true;
    }

}